package com.scalar.chiptrack.adaptor.ikanos.ams;

import Acme.HtmlObserver;

import java.net.URL;

/**
 * User: ChandraSekhar
 * Date: Jul 7, 2008
 * Time: 7:00:41 PM
 */
public class AMSHtmlObserver implements HtmlObserver
{
    private int maxFileNo = -1;
    private int maxYearNo = -1;

    public int getMaxFileNo() {
        return maxFileNo;
    }

    public void setMaxFileNo(int maxFileNo) {
        this.maxFileNo = maxFileNo;
    }

    public int getMaxYearNo() {
        return maxYearNo;
    }

    public void setMaxYearNo(int maxYearNo) {
        this.maxYearNo = maxYearNo;
    }

    public void gotAHREF( String urlString, URL contextUrl, Object clientData )
    {

        if ( urlString == null ) return;

        if ( urlString.indexOf("Ship_alert_") != -1 && urlString.indexOf("Ship Info_" ) == -1 )
        {
            int year = Integer.parseInt( urlString.substring( urlString.length()-4, urlString.length() ) );
            if ( year > getMaxYearNo()  )
            {
                setMaxYearNo( year );
            }
        }
        if ( urlString.indexOf("Ship Info_" ) != -1 )
        {
            int num = Integer.parseInt( urlString.substring(urlString.indexOf("Ship Info_" ) + "Ship Info_".length(),urlString.lastIndexOf("_") ) );
            if ( num > getMaxFileNo()  )
            {
                setMaxFileNo( num );
            }
        }

    }


    public void gotAREAHREF( String urlString, URL contextUrl, Object clientData )
    {
    }

    public void gotBASEHREF( String urlString, URL contextUrl, Object clientData )
    {
    }

    public void gotBODYBACKGROUND( String urlString, URL contextUrl, Object clientData )
    {
    }

    public void gotFRAMESRC( String urlString, URL contextUrl, Object clientData )
    {
    }

    public void gotIMGSRC( String urlString, URL contextUrl, Object clientData )
    {
    }

    public void gotLINKHREF( String urlString, URL contextUrl, Object clientData )
    {
    }

}

